package com.kuaung.mybatisplus.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kuaung.mybatisplus.entity.User;
import com.kuaung.mybatisplus.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 麻炳昌
 * @since 2024-06-23
 */
@RestController//这是一个控制器
//@RequestMapping(value = "/user",method = RequestMethod.GET)
@CrossOrigin
public class UserController {

    @Autowired//意为我要注入一个userMapper
    private UserMapper userMapper;


    @RequestMapping(value = "/user",method = RequestMethod.GET)//用户访问该方法以后我们肯定会去找mapper，从而操作数据库
    public List query() {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("id")
                .between("age",17,28);
        List<User> users = userMapper.selectList(wrapper);
        System.out.println(users);
        return users;
    }
}
